function extend(from, to = null) {
  if (from === null || typeof from !== 'object') return from;
  if (![Object, Array].includes(from.constructor)) return new from.constructor(from);
  to = to || new from.constructor();
  for (const key in from) {
    if (Object.hasOwnProperty.call(from, key)) {
      to[key] = typeof to[key] === 'undefined' ? extend(from[key], null) : to[key];
    }
  }
  return to;
}
/**
 * 深拷贝
 * @param {Array|Object} data 要深拷贝的数据
 * @param {Boolean} isSimple 是否简易模式 默认值：true
 * @returns 深拷贝后的数据
 */
module.exports = function deepClone(data, isSimple = true) {
  if (isSimple) {
    return JSON.parse(JSON.stringify(data));
  } else {
    return extend(data);
  }
};
